package com.wxy.demo.task;

import com.wxy.demo.util.JobUtils;
import org.quartz.*;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.concurrent.TimeUnit;

/***
 * <p>
 * 定时任务
 * </p>
 * @author wangxiaoyuan
 * 2021年11月30日
 */
//@DisallowConcurrentExecution
public class PrintTimeTask extends QuartzJobBean {
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        System.out.println("任务执行开始..." + JobUtils.now());
        System.out.println(JobUtils.mapToString(context.getJobDetail().getJobDataMap()));
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("任务执行结束..." + JobUtils.now());
    }
}
